<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Example</title>
</head>

<body>
  <p id="cookiedata"></p>
  <button id="write">Add Cookie</button>
  <button id="update">Update Cookie</button>
  <script>
  var cookieCount = 0;
  document.getElementById('update').onclick = updateCookie;
  document.getElementById('write').onclick = createCookie;
  readCookies();

  function readCookies() {
    document.getElementById('cookiedata').innerHTML = document.cookie;
  }

  function createCookie() {
    cookieCount++;
    document.cookie = "Cookie_" + cookieCount + "=Value_" + cookieCount;
    readCookies();
  }

  function updateCookie() {
    document.cookie = "Cookie_" + cookieCount + "=Updated_" + cookieCount;
    readCookies();
  }
  </script>
</body>

</html>
